//
//  FileInfoManager.m
//  MapEdit
//
//  Created by Steven Canfield on 7/6/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "FileInfoManager.h"


@implementation FileInfoManager
- (id)init {
	self = [super init];
	if( self ) {
		_type.type[0] = 0;
		_type.type[1] = 0;
		_type.type[2] = 0;
		_type.type[3] = 0;
		_version1.version = 0;
		_version2.version = 0;
		_version3.version = 0;
	}
	return self;
}

- (NSData *)serializedType {
	NSMutableData * data = [[NSMutableData alloc] init];
	[data appendSectionNamed:"TYPE" withBytes:&_type length:sizeof(_type)];		
	return data;
}

- (NSData *)serializedVersion1 {
	NSMutableData * data = [[NSMutableData alloc] init];
	[data appendSectionNamed:"VER " withBytes:&_version1 length:sizeof(_version1)];
	return data;
}

- (NSData *)serializedVersion2 {
	NSMutableData * data = [[NSMutableData alloc] init];
	[data appendSectionNamed:"IVER" withBytes:&_version2 length:sizeof(_version2)];
	return data;
}

- (NSData *)serializedVersion3 {
	NSMutableData * data = [[NSMutableData alloc] init];
	[data appendSectionNamed:"IVE2" withBytes:&_version3 length:sizeof(_version3)];
	return data;
}

- (NSData *)serializedVerificationCode {
	NSMutableData * data = [[NSMutableData alloc] init];
	[data appendSectionNamed:"VCOD" withBytes:&_verficationCode length:sizeof(_verficationCode)];
	return data;
}

- (NSString *)description {
	return [NSString stringWithFormat:@"TYPE = %c%c%c%c\nVER = %i\nIVER = %i\nIVE2 = %i\n", _type.type[0], _type.type[1], _type.type[2], _type.type[3], _version1.version, _version2.version, _version3.version];
}

- (void)setType:(chk_type_t)type {
	_type = type;
}

- (void)setVersion1:(chk_ver_t)version {
	_version1 = version;
}

- (void)setVersion2:(chk_iver_t)version {
	_version2 = version;
}

- (void)setVersion3:(chk_ive2_t)version {
	_version3 = version;
}

- (void)setVerificationCode:(chk_vcod_t)code {
	_verficationCode = code;
}

@end
